import { atom } from "jotai";
import type { CSSProperties } from "react";

type HeaderStore = {
  title: string;
  style: CSSProperties;
  pulse: boolean;
};

export const headerAtom = atom<HeaderStore>({
  title: "",
  style: {},
  pulse: false,
});

export const setHeaderAtom = atom(
  null,
  (get, set, update: HeaderStore | ((old: HeaderStore) => HeaderStore)) => {
    const value =
      typeof update === "function" ? update(get(headerAtom)) : update;
    set(headerAtom, value);
  },
);
